package org.example.controller;

import org.example.pojo.Result;
import org.example.pojo.Top10Vo;
import org.example.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.Map;

@RestController
@RequestMapping("/stats")
public class EchartsController {
    @Autowired
    private EchartsService echartsService;

    /**
     * 获取库存量top10
     * @return
     */
    @GetMapping("/topInventory")
    public Result<Top10Vo> Top10Inventory() {
        return Result.success(echartsService.Top10Inventory());
    }

    /**
     * 获取分类占比
     */
    @GetMapping("/categoryProportion")
    public Result categoryProportion(String timeRange) {
        return Result.success(echartsService.categoryProportion(timeRange));
    }

    /**
     * 获取概览
     */
    @GetMapping("/overview")
    public Result<Map<String, Integer>> overview() {
        return Result.success(echartsService.overview());
    }

    /**
     * 获取库存变化趋势
     */
    @GetMapping("/trend")
    public Result trend(String type, String startTime, String endTime) {
        Map<String, Object> trend = echartsService.trend(type, startTime, endTime);
        return Result.success(trend);
    }
}
